package code;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.LinkedList;


public class ClassSolver {
	private LinkedList<ClientInfo> clientInfos = new LinkedList<ClientInfo>();

	public ClientInfo getClientInfo(int problemNumber, int version) {
		for (ClientInfo i : clientInfos) {
			if (i.checkVersion(problemNumber, version)) {
				return i;
			}
		} 
		return null;
	}

	public void add(int problemNumber, int version, ObjectOutputStream out,ObjectInputStream in) {
		ClientInfo client = getClientInfo(problemNumber,version);
		if(client == null){
			clientInfos.add(new ClientInfo(problemNumber, version, out, in));
		} else {
			client.addNewClassProvider(out,in);
		}
		
	}

}
